import request from '@/utils/request'

export function getRoutes() {
  return request({
    url: '/vue-element-admin/routes',
    method: 'get'
  })
}

export function getRoles() {
  return request({
    url: '/modules/admin-role/getRoleList',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: '/modules/admin-role/addRole',
    method: 'post',
    data
  })
}

export function updateRole(id, data) {
  return request({
    url: `/vue-element-admin/role/${id}`,
    method: 'put',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: `/vue-element-admin/role/${id}`,
    method: 'delete'
  })
}
// 获取角色的权限
export function allMenus(data) {
  return request({
    url: '/api/menu/menu?roleId=' + data.roleId,
    method: 'get',
    data
  })
}
// 更新角色的权限
export function updateRoute(data) {
  return request({
    url: '/api/menu/updateRole',
    method: 'post',
    params: data
  })
}
